var Order = function () {
    return {
        Search: {
            search: function () {
                var data = $("#searchForm").serialize();
                Index.load("/admin/order/list/processing", data);
            }
        },
        Exporter: {
            export: function () {
                var data = $("#searchForm").serialize();
                window.location.href = "/admin/order/list/processing/export?" + data;
            }
        },
        Pagination: {
            goto: function (pageNo) {
                var form = $("#pageForm");
                $("#pageNo", form).val(pageNo);
                var data = form.serialize();
                Index.load("/admin/order/list/processing", data);
            }
        },
        Detail: {
            show: function (orderNo) {
                $.post("/admin/order/detail", {orderNo: orderNo}, function (data, xhr) {
                    $("#listRow").hide();
                    $("#detail").html(data).show();
                }, "text");
            },
            close: function () {
                $("#listRow").show();
                $("#detail").hide();
            }
        },
        Action: {
            updateExprStatus: function (id, status, statusName) {
                bootbox.confirm("确定要修改该订单货物状态为<span style='color:red'>【" + statusName + "】</span>么？", function (sure) {
                    if (!sure) return;
                    $.get("/admin/order/expr/status/update", {orderId: id, exprStatus: status}, function (data) {
                        if (data.code == 200) {
                            Notific8.success("修改成功");
                            Order.Initializer.refresh();
                            return;
                        }
                        Notific8.error(data.msg);
                    }, "json")
                });
            },
            orderCancel: function (id) {
                bootbox.confirm("确定要取消该订单么？", function (sure) {
                    if (!sure) return;
                    $.get("/admin/order/cancel", {orderId: id}, function (data) {
                        if (data.code == 200) {
                            Notific8.success("取消成功");
                            Order.Initializer.refresh();
                            return;
                        }
                        Notific8.error(data.msg);
                    }, "json")
                });
            }
        },
        Initializer: {
            refresh: function () {
                var pageNo = $("#pageNo", ("#pageForm")).val();
                Order.Pagination.goto(pageNo);
            },
            init: function () {
                // $(':checkbox').iCheck({
                //     checkboxClass: 'icheckbox_flat-blue',
                //     radioClass: 'iradio_flat-blue'
                // });
                Layout.fixContentHeight();

                // Layout.initHeader();
                // Layout.initContent();
                // Layout.initFooter();
            }
        }
    };
}();